<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/common/meta.jsp"%>
<title>汪星客</title>
</head>
<body>
	<div class="wrap">
		<div class="header_bg">
			<%@ include file="/common/header.jsp"%>
	    </div>
	    <div class="w">
	    	<div class="path box">
	            <img src="${ctx}/images/icon3.png" /><a class="a1" href="${ctx}/">返回首页</a><span id="pagePath"></span>
	        </div>
	    </div>
	    <div class="main">
	    	<div class="list box">
	        	<div class="detail">
	        		<input type="hidden" name="host.userId"/>
	            	<div class="d_tit"><span id="hostName"></span><em id="assessNum"></em> 份评价</div>
	                <ul id="host_show_main_button">
	                	<li class="cur" href="${ctx}/show/photo.do?id=${param['id']}">照片</li>
<%-- 	                	<li href="${ctx}/show/photo.do?id=${param['id']}">地图</li> --%>
	                	<li href="${ctx}/show/date.do?id=${param['id']}">预约日历</li>
	                </ul>
	                <div id="host_show_main_panel" class="easyui-panel" data-options="width:640,border:false" href="${ctx}/show/photo.do?id=${param['id']}">
					</div>
	                <ul><li class="cur">店铺介绍</li></ul>
	                <div class="d_main" id="hostDescribe">
					</div>
	                <ul>
	                	<li class="cur">服务评价</li>
<!-- 	                	<li>寄养相册</li> -->
	                </ul>
	                <div id="appraiseList" class="d_main" >
	                	<div class="comment">
	                        <div class="comment_m">
	                        	<h4>别忘了让狗狗的主人们给好评哦！</h4>
	                        </div>
	                    </div>
	                </div>
	            </div>
				<jsp:include page="/common/show_right.jsp"></jsp:include>
			</div>
			<div class="clear"></div>
	    </div>
	    <div class="footer_bg">
	    	<%@ include file="/common/footer.jsp"%>
	    </div>
	</div>
</body>
<script type="text/javascript">
$.getJSON("${ctx}/show/host.do?id=${param['id']}", function(host){
	showUser(host.userId);
	$("[name='host.userId']").val(host.userId);
	$("#hostName").html(host.hostName);
	//$("#assessNum").html(host.assessNum==null?0:host.assessNum);
	$("#serverVal").html("￥" + host.serverVal);
	$("#userInfo > .user_m > span > em").html(host.hostExperience);
	$("#hostAdd").html(host.cityName + " " + host.distName + " " + host.hostArea);
	$("#pagePath").append(" > <a class='a2' href='${ctx}/search.jsp?w=" + encodeURI(encodeURI(host.cityName)) + "'>" + host.cityName + "</a>");
	$("#pagePath").append(" > <a class='a2' href='${ctx}/search.jsp?w=" + encodeURI(encodeURI(host.distName)) + "'>" + host.distName + "</a>");
	$("#pagePath").append(" > <a class='a2' href='${ctx}/search.jsp?w=" + encodeURI(encodeURI(host.hostArea)) + "'>" + host.hostArea + "</a>");
	$("#pagePath").append(" > " + host.hostName);
	$("#hostDescribe").html(tools.toHtml(host.hostDescribe));
	//服务列表组装
	$.each(host.petServerList, function(i, server) {
		//获取服务html
			var getMainServer = function(name, value, valueType, liType) {
				var $li = $("<li><span>" + name + "</span></li>");
				if(liType == 1 || liType == 2) {
					$li.addClass("nbsp");
				}
				if(value != null && liType != 2) {
					$li.append($("<p><span>￥" + value + "</span>/" + valueType + "</p>"));
				} else if(value != null && liType == 2) {
					$li.append($("<p><span>" + value + " " + valueType + "</span></p>"));
				}
				return $li;
			};
			var $serverList = $("#server_list");
			if(server.petServerValuationList.length == 1) {
				var valuation = server.petServerValuationList[0];
				$serverList.append(getMainServer(server.serverName, valuation.valueVal, tendog.enum.valueType(valuation.valueType)));
			} else {
				$serverList.append(getMainServer(server.serverName));
				$.each(server.petServerValuationList, function(){
					$serverList.append(getMainServer(this.valueName, this.valueVal, tendog.enum.valueType(this.valueType), 1));
				});
			}
			if(server.petServerRestrainList.length == 1) {
				var restrain = server.petServerRestrainList[0];
				var $li = $serverList.find("li").last();
				$li.find(">span").html(server.serverName + "(" + restrain.restrainVal + tendog.enum.restrainType(restrain.restrainType) + "以内)")
			} else if(server.petServerRestrainList != null) {
				$.each(server.petServerRestrainList, function() {
					$serverList.append(getMainServer(this.restrainName, this.restrainVal, tendog.enum.restrainType(this.restrainType), 2));
				});
			}
	});
});
$(function(){
	$("#host_show_main_button > li").click(function(){
		$(this).addClass("cur").siblings().removeClass("cur");
		$("#host_show_main_panel").panel("refresh", $(this).attr("href"));
	});
	
	$.getJSON("${ctx}/show/appraise.do?id=${param['id']}", function(res) {
		if(res.rows.length > 0) {
			$("#appraiseList").html("");
		}
		$.each(res.rows, function() {
			if(this.appraise == "") {
				this.appraise = "他什么也木有留下!";
			}
			var userHead = "${ctx}/images/user_no_head.jpg";
			if(this.userPhotoPath) {
				userHead = "${ctx}/tools/download.do?dir=HEAD&fileName=" + this.userPhotoPath;
			}
			var html = "<div class='comment'>" + 
			"	<div class='comment_img'>" + 
			"		<img src='" + userHead + "' />" + 
			"	</div>" + 
			"	<div class='comment_m'>" + 
			"		<h4 style='float: left;width:200px;'>" + this.userNickName + "</h4><div class='ratyDiv' data-score='" + this.evaluate + "'></div>" + 
			"		<span>" + tools.toHtml(this.appraise) + "</span>" + 
			"	</div>" + 
			"</div>";
			
			$(html).appendTo("#appraiseList").find("img").imgAuto();
		});
		//设置评价数量
		$("#assessNum").html(res.total);
		
		$('.ratyDiv').raty({
			 path: '${cas}/js/jquery/raty/img',
			 readOnly:true,
			 score: function() {
				    return $(this).attr('data-score');
				  },
			 width:200
		});
	});
});
</script>
</html>